<template>
  <div class="test">
    <navbar />
    <APlayerComp v-if="isShow" :audio="audio" />
    <div class="app-main">
      <Nuxt />
    </div>
  </div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator' // ts装饰器
import { GetnodeMusic } from '@/plugins/axios/api' // 按需导入接口
@Component({
  name: 'layout',
})
export default class layout extends Vue {
  // ts类组件声明
  audio = {}
  isShow = false
  imgSrc = require('~/static/img/tl.JPG') // 图片地址
  // 钩子函数
  mounted(): void {
    this.getMusic()
  }
  //获取音乐
  getMusic() {
    GetnodeMusic()
      .then((res: any) => {
        console.log('getmusic', res)
        let audio = {
          id: res.data[0].id,
          name: 'Love Story',
          artist: 'Taylor Swift',
          cover: this.imgSrc,
          url: res.data[0].url,
          type: res.data[0].encodeType,
        }
        this.audio = audio
        this.isShow = true
      })
      .catch()
  }
}
</script>

<style lang="less" scoped>
.test {
  height: 100%;
}
</style>
